package com.ruoyi.framework.shiro.web.filter;

import com.ruoyi.common.utils.StringUtils;
import org.apache.shiro.web.servlet.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 参数匿名控制过滤器
 * 
 * @author ruoyi
 */
public class ParamAnonFilter extends OncePerRequestFilter
{

    @Override
    protected void doFilterInternal(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException {
        String action = servletRequest.getParameter("action");
        if(StringUtils.isNotEmpty(action)){
            HttpServletRequest request = (HttpServletRequest) servletRequest;
            request.getRequestDispatcher("/xiwo/"+action).forward(servletRequest,servletResponse);
            return;
        }
        filterChain.doFilter(servletRequest,servletResponse);
    }
}